<script setup>
const props = defineProps({
  modelValue: {
    required: true
  },
  field: {
    type: String,
    required: true
  },
  label: {
    type: String,
    required: true
  },
  rules: {
    type: Array,
    default: () => []
  },
  slotName: {
    type: String,
    required: true
  }
})

const emit = defineEmits(['update:modelValue'])

// 提供更新方法给插槽
const updateValue = (value) => {
  emit('update:modelValue', value)
}
</script>

<template>
  <el-form-item :label="label" :rules="rules" :prop="field">
    <slot
        :name="slotName"
        :value="modelValue"
        :update-value="updateValue"
    />
  </el-form-item>
</template>
